

package com.alan.app.chat;

import tomkitty.*;
import java.io.*;

public class Receive extends TurdletThread {

	private static int count = 0;
	private int myNum;

	public Receive() {
		myNum = ++count;
	}

	public void doit() {
		TkEvents.addListener(new EventListener() {
			public boolean onEvent(Object src, Object msg) {
				return handleEvent((ChatMessage) msg);
			}
		}, new ChatMessage(""));

		persist();
	}

	private boolean handleEvent(ChatMessage msg) {
		try {
			println(msg.toString());
			return true;
		} catch (IOException e) {
			Debug.d("Receive #" + myNum + ": exception: " + e.getMessage());
		}
		return false;
	}

}
